﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TetrisService
{
    /// <summary>
    /// This class represents an O tetromino. The notation is being reference as on the wikipedia.
    /// </summary>
    public class TetrominoO : Tetromino
    {
        private static readonly int COLOR = 4;
        private static readonly int COLOR_IN_ACTION = (-1) * COLOR;

        /// <summary>
        /// Initializes a new instance of the <see cref="TetrominoO"/> class.
        /// </summary>
        /// <param name="board">The board.</param>
        public TetrominoO(int[][] board)
            : base(board)
        {
            tetromino[BLOCK_0] = new TetrominoBlock(4, -1);
            tetromino[BLOCK_1] = new TetrominoBlock(4, 0);
            tetromino[BLOCK_2] = new TetrominoBlock(5, -1);
            tetromino[BLOCK_3] = new TetrominoBlock(5, 0);
            fillCurrentTetromino(COLOR_IN_ACTION);

        }

        /// <summary>
        /// the tetromino O is always the same.
        /// </summary>
        /// <returns></returns>
        public override bool rotate()
        {
            return true;
        }

        /// <summary>
        /// Returns the color of the tetromino.
        /// </summary>
        /// <returns></returns>
        public override int color()
        {
            return COLOR;
        }
        /// <summary>
        /// When a line is done by the player, it should be erased. Because of that, we decided
        /// to represent the piece that is falling down by a different state, which is represented
        /// by a color, so when we move down all the blocks above the line that was made, the
        /// tetromino that is falling should not move down.
        /// </summary>
        /// <returns></returns>
        protected override int colorWhileFalling()
        {
            return COLOR_IN_ACTION;
        }
    }
}